<template>
	<!-- 拒绝退货 & 修改理由 弹窗 -->
	<ayjDialog ref="dialogRef" :title="title" :width="'30%'">
		<view class="cate-content">
			<div class="input-value">
				<el-input v-model="inputValue" :placeholder="tip" type="text" />
			</div>
			<div class="mb10 mr10" style="text-align: right;">
				<el-button type="primary" size="mini" @click="sure">{{ sureTxt }}</el-button>
			</div>
		</view>
	</ayjDialog>
</template>

<script>
import staticConst from "../../js/const/StaticConst.js";
import util from '../../js/util/Util.js';
import config from "../../js/conf/Config.js";

import lang from "../../js/conf/Lang.js";
import https from "../../js/https/Https.js";

export default {
	data() {
		return {
			title: "",
			tip: lang.customerTxt.addTipTxt,
			sureTxt: lang.confirm,
			inputValue: "",
			openShow: 0,
			callBack: null,
			act: 0, //1:新增 ; 2:编辑
			item: null,
		};
	},
	methods: {

		show(type, data) {
			if (!type) return;
			if (!data) return;
			this.$refs.dialogRef.open();
			this.inputValue = "";
			this.title = data.title;
			this.act = data.act;
			if (this.act == 2 && data.item) {
				this.item = data.item;
				this.inputValue = this.item.title;
			}
		},

		sure() {
			// this.show();
			this.addAndEdit()
		},

		/****新增/编辑提提交数据**/
		addAndEdit() {
			let value = util.trim(this.inputValue);
			if (!value) return;
			let that = this;
			let param = {};
			if (this.act == 1) {
				param.id = 0;
			}
			else {
				param.id = this.item.id;
			}
			param.title = this.inputValue;
			https.customTagSave(param, back);
			function back(data) {
				if (!data) return;
				if (data.status == 1) {
					that.$emit("saveTagSuccess");
					that.$refs.dialogRef.close();
				}
			}
		},
	},
}
</script>
<style lang="scss" scoped>
.input-value {
	margin: 40px 10px;
}
</style>